package com.recharge.web.controller;

import com.recharge.common.result.ResultDO;
import com.recharge.common.result.web.ObjectResponse;
import com.recharge.domain.query.UserLoginLogQueryDO;
import com.recharge.service.UserLoginLogService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <h1>描述: 用户登录日志</h1>
 * @author kui
 * @date 2020/8/24 15:04
 */
@RestController
@RequestMapping("/user-login-log")
public class UserLoginLogController {

    @Autowired
    UserLoginLogService userLoginLogService;

    @RequiresPermissions("user-login-log:page")
    @RequestMapping(value="/page.html", method = RequestMethod.POST)
    @ApiOperation(value = "查询登录日志")
    public @ResponseBody
    ObjectResponse page(@RequestBody UserLoginLogQueryDO domain) {
        ObjectResponse response = new ObjectResponse();

        ResultDO result = userLoginLogService.find(domain);
        if (result.isSuccess()) {
            response.setData(result.getModel(ResultDO.FIRST_MODEL_KEY));
        } else {
            response.setStatus(result.getErrorCode().getCode());
            response.setMsg(result.getErrorCode().getMsg());
        }
        return response;
    }


}
